/*
 * IAIC2View.java
 */

package iaic2;

import iaic2.conectores.ConectorCoaching;
import iaic2.conectores.ConectorTecnico;
import iaic2.conectores.FactoriaConectoresAbs;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.io.File;
import java.util.Iterator;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import jess.JessException;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import javax.swing.JFrame;
import javax.swing.JLabel;
import jess.Rete;

/**
 * The application's main frame.
 */
public class IAIC2View extends FrameView {

    public IAIC2View(SingleFrameApplication app) {
        super(app);
        // Inicializamos el razonador.
        this.razonador = new Rete();

        initComponents();
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jComboBox2 = new javax.swing.JComboBox();
        jComboBox3 = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        jComboBox4 = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        jComboBox5 = new javax.swing.JComboBox();
        jLabel10 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jComboBox6 = new javax.swing.JComboBox();
        jComboBox7 = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jComboBox8 = new javax.swing.JComboBox();

        mainPanel.setName("mainPanel"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(iaic2.IAIC2App.class).getContext().getResourceMap(IAIC2View.class);
        jTabbedPane1.setFont(resourceMap.getFont("jTabbedPane1.font")); // NOI18N
        jTabbedPane1.setName("jTabbedPane1"); // NOI18N

        jPanel1.setName("jPanel1"); // NOI18N

        jButton1.setFont(resourceMap.getFont("jButton1.font")); // NOI18N
        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel1.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jComboBox1.setFont(resourceMap.getFont("intProfesional.font")); // NOI18N
        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Informatica", "Economia", "Hosteleria", "Turismo", "Derecho", "Telecomunicaciones", "Salud" }));
        jComboBox1.setName("intProfesional"); // NOI18N

        jLabel2.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel3.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel4.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jComboBox2.setFont(resourceMap.getFont("idioHablado.font")); // NOI18N
        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-----", "Alto", "Medio", "Bajo" }));
        jComboBox2.setName("idioHablado"); // NOI18N

        jComboBox3.setFont(resourceMap.getFont("idioEscrito.font")); // NOI18N
        jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-----", "Alto", "Medio", "Bajo" }));
        jComboBox3.setName("idioEscrito"); // NOI18N

        jLabel5.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jComboBox4.setFont(resourceMap.getFont("nEstudios.font")); // NOI18N
        jComboBox4.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ESO", "Bachillerato", "FP Grado Medio", "FP Grado Superior", "Diplomatura", "Licenciatura" }));
        jComboBox4.setName("nEstudios"); // NOI18N

        jLabel6.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jComboBox5.setFont(resourceMap.getFont("expLaboral.font")); // NOI18N
        jComboBox5.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Ninguna", "0-2", "2-5", "5-10", "10+" }));
        jComboBox5.setName("expLaboral"); // NOI18N

        jLabel10.setFont(resourceMap.getFont("jLabel10.font")); // NOI18N
        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(163, 163, 163)
                        .addComponent(jButton1))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(136, 136, 136)
                        .addComponent(jLabel10))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(49, 49, 49)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGap(66, 66, 66)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel4)
                                            .addComponent(jLabel3)))
                                    .addComponent(jLabel1))
                                .addGap(45, 45, 45)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jComboBox1, 0, 126, Short.MAX_VALUE)
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jComboBox5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jComboBox4, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))))
                            .addComponent(jLabel5)
                            .addComponent(jLabel6))))
                .addContainerGap(51, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel10)
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addGap(5, 5, 5)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(12, 12, 12)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jComboBox5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 28, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addContainerGap())
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel1.TabConstraints.tabTitle"), jPanel1); // NOI18N

        jPanel2.setName("jPanel2"); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 416, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 276, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel2.TabConstraints.tabTitle"), jPanel2); // NOI18N

        jPanel3.setName("jPanel3"); // NOI18N

        jComboBox6.setFont(resourceMap.getFont("jComboBox6.font")); // NOI18N
        jComboBox6.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Estudiando", "Poca", "Mucha" }));
        jComboBox6.setName("jComboBox6"); // NOI18N

        jComboBox7.setFont(resourceMap.getFont("jComboBox7.font")); // NOI18N
        jComboBox7.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Realizacion", "Dinero" }));
        jComboBox7.setName("jComboBox7"); // NOI18N

        jLabel7.setFont(resourceMap.getFont("jLabel7.font")); // NOI18N
        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel8.setFont(resourceMap.getFont("jLabel8.font")); // NOI18N
        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jLabel9.setFont(resourceMap.getFont("jLabel9.font")); // NOI18N
        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        jLabel11.setFont(resourceMap.getFont("jLabel11.font")); // NOI18N
        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        jButton2.setFont(resourceMap.getFont("jButton2.font")); // NOI18N
        jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
        jButton2.setName("jButton2"); // NOI18N
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jComboBox8.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "<27", "27-45", ">45" }));
        jComboBox8.setName("jComboBox8"); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(74, 74, 74)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel7)
                    .addComponent(jLabel9)
                    .addComponent(jLabel8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 97, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jComboBox8, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jComboBox6, 0, 99, Short.MAX_VALUE)
                    .addComponent(jComboBox7, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(78, 78, 78))
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(134, 134, 134)
                .addComponent(jLabel11)
                .addContainerGap(117, Short.MAX_VALUE))
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(165, 165, 165)
                .addComponent(jButton2)
                .addContainerGap(164, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel11)
                .addGap(36, 36, 36)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel8)
                        .addGap(13, 13, 13)
                        .addComponent(jLabel9))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBox8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBox6, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBox7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 95, Short.MAX_VALUE)
                .addComponent(jButton2)
                .addContainerGap())
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel3.TabConstraints.tabTitle"), jPanel3); // NOI18N

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 421, Short.MAX_VALUE)
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 302, Short.MAX_VALUE)
        );

        setComponent(mainPanel);
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        try {

            //Cargamos las reglas desde cero, vaciando el razonador.
            // Para evitar posibles reglas duplicadas.
            this.razonador.clear();

            File f = new File("BR/Tecnico.rules");
            String ruta = f.getAbsolutePath().replace("\\", "/");
            this.razonador.executeCommand("(batch "+ruta+")");
            
            switch (Integer.valueOf(jComboBox1.getSelectedIndex())){
                case 0:
                    this.razonador.executeCommand("(assert (InteresProfesional Informatica) )");
                    break;
                case 1:
                    this.razonador.executeCommand("(assert (InteresProfesional Economia) )");
                    break;
                case 2:
                    this.razonador.executeCommand("(assert (InteresProfesional Hosteleria) )");
                    break;
                case 3:
                    this.razonador.executeCommand("(assert (InteresProfesional Turismo) )");
                    break;
                case 4:
                    this.razonador.executeCommand("(assert (InteresProfesional Derecho) )");
                    break;
                case 5:
                    this.razonador.executeCommand("(assert (InteresProfesional Telecomunicaciones) )");
                    break; 
                case 6:
                    this.razonador.executeCommand("(assert (InteresProfesional Salud) )");
                    break;                     
            }
            
            // Consideramos el idioma una faceta indispensable para trabajos tecnicos.
            //I que se debe tener un nivel similar de Hablado y Escrito
            if ( !jComboBox2.getSelectedItem().toString().equals(String.valueOf("-----")) )
                this.razonador.executeCommand("(assert (NivelHablado " + jComboBox2.getSelectedItem().toString() + ") )");
            else 
                this.razonador.executeCommand("(assert (NivelHablado Bajo) )");
            
            if ( !jComboBox3.getSelectedItem().toString().equals(String.valueOf("-----")) )
                this.razonador.executeCommand("(assert (NivelEscrito " + jComboBox3.getSelectedItem().toString() + ") )");
            else
                this.razonador.executeCommand("(assert (NivelEscrito Bajo) )");
            
            switch (Integer.valueOf(jComboBox4.getSelectedIndex())){
                case 0:
                    this.razonador.executeCommand("(assert (Estudios ESO) )");
                    break;
                case 1:
                    this.razonador.executeCommand("(assert (Estudios Bachillerato) )");
                    break;
                case 2:
                    this.razonador.executeCommand("(assert (Estudios FPGradoMedio) )");
                    break;
                case 3:
                    this.razonador.executeCommand("(assert (Estudios FPGradoSuperior) )");
                    break;
                case 4:
                    this.razonador.executeCommand("(assert (Estudios Diplomatura) )");
                    break;
                case 5:
                    this.razonador.executeCommand("(assert (Estudios Licenciatura) )");
                    break;                    
            }
            
            switch (Integer.valueOf(jComboBox5.getSelectedIndex())){
                case 0:
                    this.razonador.executeCommand("(assert (Experiencia 0) )");
                    break;
                case 1:
                    this.razonador.executeCommand("(assert (Experiencia [0-2]) )");
                    break;
                case 2:
                    this.razonador.executeCommand("(assert (Experiencia [2-5]) )");
                    break;
                case 3:
                    this.razonador.executeCommand("(assert (Experiencia [5-10]) )");
                    break;
                case 4:
                    this.razonador.executeCommand("(assert (Experiencia 10) )");
                    break;                    
            }


            this.razonador.run();
                // Llegados a este punto tenemos las 2 reglas resultantes
                // esperando ser extraidas para mostrar las conclusiones

            String tipoCV = null;
            String perfil = null;
            String nProfesional = null;
            Vector<String> dondeBuscar = new Vector<String>();
            Iterator hechos = this.razonador.listFacts();
            while(hechos.hasNext()) {

                String element = hechos.next().toString();
                if (element.contains("TipoCV")){
                    String[] aux = element.split(" ");
                    tipoCV = aux[1].substring(0,aux[1].length()-1);
                }
                if (element.contains("DondeBuscar")){
                    String[] aux = element.split(" ");
                    dondeBuscar.add(aux[1].substring(0,aux[1].length()-1));
                }
                if (element.contains("Perfil")){
                    String[] aux = element.split(" ");
                    perfil = aux[1].substring(0,aux[1].length()-1);
                }
                if (element.contains("NivelProfesional")){
                    String[] aux = element.split(" ");
                    nProfesional = aux[1].substring(0,aux[1].length()-1);
                }
                System.out.print(element+", ");
            }

            if (tipoCV == null){
                //No se proceso la peticion porque el perfil del candidato es pobre
                // POnerlo en un panel bonito como el resto
                JFrame frame = new JFrame("Mejora tu CV");
                frame.setSize(400, 100);
                frame.setLayout(new GridLayout(3,1));
                frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                frame.getContentPane().add(new JLabel("\nPara un perfil "+perfil+" y un nivel profesional "+nProfesional), BorderLayout.CENTER);
                frame.getContentPane().add(new JLabel("\tno te podemos ayudar, debes conseguir mas experiencia y estudios superiores"), BorderLayout.CENTER);
                frame.getContentPane().add(new JLabel("y tal vez mejorar un poco tus idiomas."), BorderLayout.CENTER);
                frame.setVisible(true);
            }else{
                // Tipo CV
                System.out.println("\n\nTipo de CV:");
                System.out.println("\t"+tipoCV);

                // Donde buscar trabajo
                // TODO: En vez de mostrar donde, indicar ejemplos de ETT, paginasG paginasEsp etc.
                System.out.println("\nTe aconsejamos buscar trabajo en:");
                System.out.println("\t"+dondeBuscar.toString());
                
                //Mostramos el formulario
                resultadoTecnico panelInfo = new resultadoTecnico();
            
                ConectorTecnico conn = FactoriaConectoresAbs.getInstancia().generaConectorTecnico();

                conn.loadConfigFile();

                panelInfo.setInfo(conn.getPropiedades().get((String)tipoCV),conn.getCiertasWebs(dondeBuscar));
                panelInfo.setVisible(true);

                panelInfo.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
            }

            this.razonador.clear();            

        } catch (JessException ex) {
            Logger.getLogger(IAIC2View.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // Aqui se va a ejecutar el enfoque de coaching        
        try {
            
            //Cargar reglas de Coaching
            this.razonador.clear();

            File f = new File("BR/Coaching.rules");
            String ruta = f.getAbsolutePath().replace("\\", "/");
            this.razonador.executeCommand("(batch "+ruta+")");
            
            // Insertamos la edad como hecho
            this.razonador.executeCommand("(assert (anios "+jComboBox8.getSelectedItem().toString().toLowerCase()+"))");
            this.razonador.executeCommand("(assert (experiencia "+jComboBox6.getSelectedItem().toString().toLowerCase()+"))");
            this.razonador.executeCommand("(assert (motivacion "+jComboBox7.getSelectedItem().toString().toLowerCase()+"))");
            
            this.razonador.run();

            String consejo = null;
            Iterator hechos = this.razonador.listFacts();
            while(hechos.hasNext()) {
                String element = hechos.next().toString();
                if (element.contains("conclusion")){
                    String[] aux = element.split(" ");
                    consejo = aux[1].substring(0,aux[1].length()-1);
                }
            }

            if( consejo != null){
                //Mostramos el formulario
                resultadoCoaching panelInfo = new resultadoCoaching();
            
                ConectorCoaching conn = FactoriaConectoresAbs.getInstancia().generaConectorCoaching();

                conn.loadConfigFile();

                panelInfo.setInfo(conn.getConsejos().get(consejo));
                panelInfo.setVisible(true);

                panelInfo.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
            }else{
                // Hubo algun error o la regla no esta contemplada.
                System.out.println("No esta contemplada la regla.");
            }

            this.razonador.clear();
        } catch (JessException ex) {
            System.out.println(ex);
        }
        

    }//GEN-LAST:event_jButton2ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JComboBox jComboBox3;
    private javax.swing.JComboBox jComboBox4;
    private javax.swing.JComboBox jComboBox5;
    private javax.swing.JComboBox jComboBox6;
    private javax.swing.JComboBox jComboBox7;
    private javax.swing.JComboBox jComboBox8;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JPanel mainPanel;
    // End of variables declaration//GEN-END:variables

    private Rete razonador;
}
